package com.dliu.javadesign.structure.adapter;

/**
 *
 * @author yanglei
 * date 2021/3/30 15:40
 */
public interface ChargeLine {
    void charge(String type, String teleName);

    class AndroidLine implements ChargeLine {

        @Override
        public void charge(String type, String teleName) {
            if ("android".equalsIgnoreCase(type)){
                System.out.println(teleName + ": 安卓充电线");
            }else if ("apple".equalsIgnoreCase(type) || "typec".equalsIgnoreCase(type)){
                AndroidLineAdapter adapter = new AndroidLineAdapter();
                adapter.charge(type, teleName);
            }
        }
    }

    class AndroidLineAdapter implements ChargeLine {
        OtherChargeLine otherChargeLine;
        @Override
        public void charge(String type, String teleName) {
            if ("apple".equalsIgnoreCase(type)){
                otherChargeLine = new OtherChargeLine.AppleLine();
                otherChargeLine.appleCharge(teleName);
            }
            if ("typec".equalsIgnoreCase(type)){
                otherChargeLine = new OtherChargeLine.TypeCLine();
                otherChargeLine.typeCCharge(teleName);
            }
        }
    }

    static void main(String[] args) {
        AndroidLine androidLine = new AndroidLine();
        androidLine.charge("apple", "iPone12");
        androidLine.charge("typec", "huaweiP30");
        androidLine.charge("android", "三星盖世");
    }
}
